<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Xuan的博客 - Xuan.top</title><meta name="author" content="Xuan"><meta name="copyright" content="Xuan"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta property="og:type" content="website">
<meta property="og:title" content="Xuan的博客">
<meta property="og:url" content="http://leesmile.gitee.io/smile/page/11/index.html">
<meta property="og:site_name" content="Xuan的博客">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://leesmile.gitee.io/smile/img/avatarImg.bmp">
<meta property="article:author" content="Xuan">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://leesmile.gitee.io/smile/img/avatarImg.bmp"><link rel="shortcut icon" href="/smile/img/favicon.png"><link rel="canonical" href="http://leesmile.gitee.io/smile/page/11/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/smile/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/smile/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Xuan的博客',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2024-04-09 09:45:27'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/font.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/whiteLine.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/progress_bar.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/cat.css"><link rel="stylesheet" href="/css/readPercent.css"><link rel="stylesheet" href="https://cdn1.tianli0.top/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css"><div id="myscoll"></div><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://leesmile.gitee.io/smile/img/avatarImg.bmp" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/smile/archives/"><div class="headline">文章</div><div class="length-num">142</div></a><a href="/smile/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/smile/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/smile/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/smile/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/smile/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/smile/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="page home" id="body-wrap"><header class="full_page" id="page-header"><nav id="nav"><span id="blog-info"><a href="/smile/" title="Xuan的博客"><span class="site-name">Xuan的博客</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/smile/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/smile/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/smile/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/smile/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="nav-right"><a class="meihua faa-parent animated-hover" onclick="toggleWinbox()" title="美化设置-自定义你的风格" id="meihua-button"><svg class="faa-tada icon" style="height:26px;width:26px;fill:currentColor;position:relative;top:8px" aria-hidden="true"><use xlink:href="#icon-tupian1"></use></svg></a><a class="sun_moon faa-parent animated-hover" onclick="switchNightMode()" title="浅色和深色模式转换" id="nightmode-button"><svg class="faa-tada" style="height:25px;width:25px;fill:currentColor;position:relative;top:7px" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"></use></svg></a></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">Xuan的博客</h1></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="recent-post-content left"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Socket"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/17/Java/JavaSE/Socket/" title="Socket"><div class="article-title-link">Socket</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-17T01:53:46.000Z" title="发表于 2023-06-17 09:53:46">2023-06-17</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaSE/">JavaSE</a></span></div></div></div><a class="article-content" href="/smile/2023/06/17/Java/JavaSE/Socket/" title="Socket"><div class="article-content-text">Socket使用Scoket实现服务端和客户端通信的例子
先在服务端定义ServerSocket和Socket属性以及输入输出流为null
实例化new ServerSocket(8888)到本机端口号8888
循环接受客户端发送的socket对象
客户端实例化Socket对象，本机端口8888
通过dataOutputStream.writeUTF(request)，写入请求内容
发送socket到服务端
接收到socket后
使用serverSocket.accept()接受socket
获取输入流并通过dataInputStream.readUTF()获取接收到的请求内容
传入输出流，通过dataOutputStream.writeUTF写入响应结果，发送给客户端
发送socket给服务端
客户端收到服务器的响应结果
socket.getInputStream()获取接收到的Socket返回的响应结果
服务端
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474 ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310261532737.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Servlet+Jsp实现CRUD"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/16/Java/JavaWeb/Servlet+Jsp%E5%AE%9E%E7%8E%B0CRUD/" title="Servlet+Jsp实现CRUD"><div class="article-title-link">Servlet+Jsp实现CRUD</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-16T01:53:46.000Z" title="发表于 2023-06-16 09:53:46">2023-06-16</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaWeb/">JavaWeb</a></span></div></div></div><a class="article-content" href="/smile/2023/06/16/Java/JavaWeb/Servlet+Jsp%E5%AE%9E%E7%8E%B0CRUD/" title="Servlet+Jsp实现CRUD"><div class="article-content-text">Servlet+Jsp实现CRUD使用Servlet+Jsp实现，add、deleteById、getById、list、update方法
Servletadd
1234567891011121314151617181920212223242526272829303132package com.servlet;import com.data.MyDB;import com.entity.User;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;@WebServlet(&quot;/add&quot;)public class AddServlet extends Ht ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310261532737.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="会话"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/15/Java/JavaWeb/%E4%BC%9A%E8%AF%9D/" title="会话"><div class="article-title-link">会话</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-15T01:53:46.000Z" title="发表于 2023-06-15 09:53:46">2023-06-15</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaWeb/">JavaWeb</a></span></div></div></div><a class="article-content" href="/smile/2023/06/15/Java/JavaWeb/%E4%BC%9A%E8%AF%9D/" title="会话"><div class="article-content-text">会话会话用来区分请求分别来自哪些客户端，浏览器和服务器之间发生的一系列连续的请求和响应的过程，打开浏览器到关闭浏览器的全过程。
Session123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310261532737.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Servlet"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/15/Java/JavaWeb/Servlet/" title="Servlet"><div class="article-title-link">Servlet</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-15T01:53:46.000Z" title="发表于 2023-06-15 09:53:46">2023-06-15</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaWeb/">JavaWeb</a></span></div></div></div><a class="article-content" href="/smile/2023/06/15/Java/JavaWeb/Servlet/" title="Servlet"><div class="article-content-text">Servlet最基础的 Java Web 开发组件：Servlet + JSP
ServletJava 提供的进行 Web 开发的组件，接口：具备接收 HTTP 请求以及做出响应的功能
基于 Servlet 写的 Web 程序需要通过加载到 WEB 应用服务器（Tomcat）中，才能被外部访问
Java Web 工程 和 Java 工程区别1、依赖 jar 不同
2、是否支持 Web 资源访问
MyGenericServlet 隐藏非必须的方法程序启动之后，Servlet 只会创建一个对象，单例模式init 方法也只调用一次，当第一次访问该 Servlet 的时候进行创建，并且调用 init 方法
destory 方法也只调用一次，当关闭 Tomcat 的时候调用
service 方法会多次调用，每一次请求 Servlet 都会调用 service 方法完成相应的业务逻辑
因此5 个方法只用 1 个，4 个是非必须的方法，如何屏蔽 4 个非必须的方法？
提供了一个父类MyGenericServlet ，由该父类实现 Servlet 接口，并且实现 5 个方法
业务 Servlet 只需 ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310261532737.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="重定向和转发"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/15/Java/JavaWeb/%E9%87%8D%E5%AE%9A%E5%90%91%E5%92%8C%E8%BD%AC%E5%8F%91/" title="重定向和转发"><div class="article-title-link">重定向和转发</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-15T01:53:46.000Z" title="发表于 2023-06-15 09:53:46">2023-06-15</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaWeb/">JavaWeb</a></span></div></div></div><a class="article-content" href="/smile/2023/06/15/Java/JavaWeb/%E9%87%8D%E5%AE%9A%E5%90%91%E5%92%8C%E8%BD%AC%E5%8F%91/" title="重定向和转发"><div class="article-content-text">重定向和转发JSPJava Server Page Java 服务页面，是一个模板，编辑 HTML 代码的模板，中间层的组件，可以在 JSP 中编写要返回的 HTML 代码，JSP 最终会生成一个 Servlet，将 HTML 通过 out 进行输出。
JSP 内置对象，不用开发者声明而可以直接使用的对象，JSP 最终会转换成一个 Servlet，Servlet 的方法中已经将这些内置对象进行了声明，所以可以直接用。
转发和重定向服务器接收到请求之后，做出响应的两种不同形式，以不同的形式返回页面数据。
转发：在保留当前请求的情况下，进行页面跳转，同一次请求，在服务器端进行的，地址栏不变
不需要进行响应，直接在服务器内部进行跳转，服务器跳转
重定向：开启一次新的请求进行页面跳转，两次请求，在浏览器端进行的，地址栏会改变
先响应，需要浏览器重新发送请求，客户端跳转
如果通过 request 进行数据传递，必须使用转发，重定向失效，因为是不同的请求。
1234//转发request.getRequestDispatcher(&quot;login-success.html&quot;).fo ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="WebContainer# 文章名称"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/13/Java/JavaSE/WebContainer/" title="WebContainer# 文章名称"><div class="article-title-link">WebContainer# 文章名称</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-13T01:53:46.000Z" title="发表于 2023-06-13 09:53:46">2023-06-13</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaSE/">JavaSE</a></span></div></div></div><a class="article-content" href="/smile/2023/06/13/Java/JavaSE/WebContainer/" title="WebContainer# 文章名称"><div class="article-content-text">WebContainerMyHttpServer服务端
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758package com.example.webcontainer;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.ServerSocket;import java.net.Socket;public class MyHttpServer &#123;    // 获取WebContent文件夹的位置，以读取index.html文件    public static String WebContent = System.getProperty(&quot;user.dir&quot;) + File.separator + &quot;W ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271417789.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="SQL函数"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/11/SQL/MySQL%E5%87%BD%E6%95%B0/" title="SQL函数"><div class="article-title-link">SQL函数</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-11T01:53:46.000Z" title="发表于 2023-06-11 09:53:46">2023-06-11</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/MySQL/">MySQL</a></span></div></div></div><a class="article-content" href="/smile/2023/06/11/SQL/MySQL%E5%87%BD%E6%95%B0/" title="SQL函数"><div class="article-content-text">SQL函数






</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="DbUtil"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/09/Java/DbUtil/" title="DbUtil"><div class="article-title-link">DbUtil</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-09T01:53:46.000Z" title="发表于 2023-06-09 09:53:46">2023-06-09</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/MySQL/">MySQL</a></span></div></div></div><a class="article-content" href="/smile/2023/06/09/Java/DbUtil/" title="DbUtil"><div class="article-content-text">DbUtilDbUtil的作用简化了执行sql和结果集解析的过程，只需要传入connection和SQL即可获取到结果
执行SQL查询并接受结果集创建QueryRunner对象，使用queryRunner.query()，传入三个参数

connection：连接
sql：SQL语句
ResultSetHandler：解析结果集的返回值数据类型

通过反射Account类获取结果集new BeanListHandler(Account.class)
1234567891011public static void query2() throws Exception&#123;    Connection connection = JDBCUtil.getConnection();    QueryRunner queryRunner = new QueryRunner();    String sql = &quot;select * from account&quot;;    List&lt;Account&gt; list = queryRunner.query(connectio ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="JDBC"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/09/Java/JDBC/" title="JDBC"><div class="article-title-link">JDBC</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-09T01:53:46.000Z" title="发表于 2023-06-09 09:53:46">2023-06-09</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/MySQL/">MySQL</a></span></div></div></div><a class="article-content" href="/smile/2023/06/09/Java/JDBC/" title="JDBC"><div class="article-content-text">JDBCJDBC是什么?Java DataBase Connectivity，提供了一套API，可在不修改代码的前提下操作不同的数据库
接口包括两个层面：

面向应用的API，开发人员使用
DriverManager 管理驱动程序
Connection 连接数据库
Statement 执行数据库语句
ResultSet 收集执行结果


面向数据库开发商的API，供数据库厂商（驱动）调用

JDBC访问数据库过程
加载数据库驱动
获取Connection，一次连接
通过Statement执行sql语句
通过ResultSet获取执行结果

封装JDBCUtil的过程加载驱动，获取连接，释放资源的过程
JDBCUtil
123456789101112131415161718192021222324252627282930313233343536373839404142package com.example;import java.sql.*;public class JDBCUtil &#123;    static&#123;        //  加载驱动        try &# ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="数据库连接池"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/09/Java/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%BF%9E%E6%8E%A5%E6%B1%A0/" title="数据库连接池"><div class="article-title-link">数据库连接池</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-09T01:53:46.000Z" title="发表于 2023-06-09 09:53:46">2023-06-09</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/MySQL/">MySQL</a></span></div></div></div><a class="article-content" href="/smile/2023/06/09/Java/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%BF%9E%E6%8E%A5%E6%B1%A0/" title="数据库连接池"><div class="article-content-text">数据库连接池数据库连接池是什么？数据库每次获取连接都需要验证账号密码等，频繁的创建连接会浪费时间和资源
可以通过数据库连接池的方式，在创建完连接池后，需要使用就从连接池中获取连接，使用完连接就放回到连接池中
JDBC的数据库连接池使用javax.sql.DataSource来完成，DataSource是由Java官方提供的接口
具体的实现类有C3P0和Alibaba的Druid
通过调用重写的getConnect()方法从连接池中获取连接
创建Druid连接池
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849package org.example;import com.alibaba.druid.pool.DruidDataSource;import java.sql.Connection;public class JDBCUtil &#123;    private DruidDataSource dataSource = null;    private ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="反射# 文章名称"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/08/Java/JavaSE/%E5%8F%8D%E5%B0%84/" title="反射# 文章名称"><div class="article-title-link">反射# 文章名称</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-08T01:53:46.000Z" title="发表于 2023-06-08 09:53:46">2023-06-08</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaSE/">JavaSE</a></span></div></div></div><a class="article-content" href="/smile/2023/06/08/Java/JavaSE/%E5%8F%8D%E5%B0%84/" title="反射# 文章名称"><div class="article-content-text">反射通过forName()可以获取到类方法，传入参数为类的包名.类名
再通过getConstructor()获取构造器，最后通过构造器的newInstance()方法实例化对象
通过反射创建类实例对象
123456789101112131415161718192021222324252627package com.example.reflection;import java.lang.reflect.Constructor;public class GetClass &#123;    public static void main(String[] args) &#123;        createobj(&quot;org.example.entity.Address&quot;);        createobj(&quot;org.example.entity.User&quot;);        createobj(&quot;java.lang.String&quot;);    &#125;    // 通过反射创建对象    public static void  ...</div></a><div class="recent-post-arrow"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><div class="recent-post-cover"><img class="article-cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Proxy代理"></div><div class="recent-post-info"><a class="article-title" href="/smile/2023/06/07/Java/JavaSE/Proxy%E4%BB%A3%E7%90%86/" title="Proxy代理"><div class="article-title-link">Proxy代理</div></a><div class="recent-post-meta"><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-06-07T01:53:46.000Z" title="发表于 2023-06-07 09:53:46">2023-06-07</time></span><span class="article-meta"><span class="article-meta-separator"> |</span><svg class="meta_icon post-ui-icon" style="width:12px;height:12px;position:relative;top:1px"><use xlink:href="#icon-fenlei"></use></svg><a class="article-meta__categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/smile/categories/Java/JavaSE/">JavaSE</a></span></div></div></div><a class="article-content" href="/smile/2023/06/07/Java/JavaSE/Proxy%E4%BB%A3%E7%90%86/" title="Proxy代理"><div class="article-content-text">Proxy代理静态代理使用接口类型接收不同的实例，并重写car()方法返回代理代码
Car接口
12345package com.example.proxy;public interface Car &#123;    public String car();&#125;


Car第一个实例Benz
123456789package com.example.proxy;public class CarBenZ implements Car&#123;    @Override    public String car() &#123;        return &quot;Benz&quot;;    &#125;&#125;


Car第二个实例BMW
12345678910package com.example.proxy;public class CarBMW implements Car&#123;    @Override    public String car() &#123;        return &quot;BMW&quot;;    &#125;&#125 ...</div></a><div class="recent-post-arrow"></div></div></div><nav id="pagination"><div class="pagination"><a class="extend prev" rel="prev" href="/smile/page/10/#content-inner"><i class="fas fa-chevron-left fa-fw"></i></a><a class="page-number" href="/smile/">1</a><span class="space">&hellip;</span><a class="page-number" href="/smile/page/10/#content-inner">10</a><span class="page-number current">11</span><a class="page-number" href="/smile/page/12/#content-inner">12</a><a class="extend next" rel="next" href="/smile/page/12/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="author_top is-center"><div class="avatar-img"><img src="https://leesmile.gitee.io/smile/img/avatarImg.bmp" onerror="this.onerror=null;this.src='/smile/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Xuan</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/smile/archives/"><div class="headline">文章</div><div class="length-num">142</div></a><a href="/smile/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/smile/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/04/08/%E4%B8%8D%E5%90%8C%E8%A7%92%E5%BA%A6%E5%87%BA%E5%8F%91%E5%8E%BB%E9%9C%80%E6%B1%82%E6%B2%9F%E9%80%9A%E9%97%AE%E9%A2%98/" title="不同角度出发去需求沟通问题"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="不同角度出发去需求沟通问题"/></a><div class="content"><a class="title" href="/smile/2024/04/08/%E4%B8%8D%E5%90%8C%E8%A7%92%E5%BA%A6%E5%87%BA%E5%8F%91%E5%8E%BB%E9%9C%80%E6%B1%82%E6%B2%9F%E9%80%9A%E9%97%AE%E9%A2%98/" title="不同角度出发去需求沟通问题">不同角度出发去需求沟通问题</a><time datetime="2024-04-08T07:55:46.000Z" title="发表于 2024-04-08 15:55:46">2024-04-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/04/01/%E4%BA%A7%E5%93%81%E5%95%86%E4%B8%9A%E8%AE%A1%E5%88%92%E6%96%B9%E5%90%91%E6%80%9D%E8%80%83/" title="产品商业计划方向思考"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="产品商业计划方向思考"/></a><div class="content"><a class="title" href="/smile/2024/04/01/%E4%BA%A7%E5%93%81%E5%95%86%E4%B8%9A%E8%AE%A1%E5%88%92%E6%96%B9%E5%90%91%E6%80%9D%E8%80%83/" title="产品商业计划方向思考">产品商业计划方向思考</a><time datetime="2024-04-01T07:55:46.000Z" title="发表于 2024-04-01 15:55:46">2024-04-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/28/%E5%85%AC%E5%8F%B8%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%90%BD%E5%9C%B0%E7%9A%84%E9%9A%BE%E7%82%B9/" title="公司自动化测试落地的难点"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="公司自动化测试落地的难点"/></a><div class="content"><a class="title" href="/smile/2024/03/28/%E5%85%AC%E5%8F%B8%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%90%BD%E5%9C%B0%E7%9A%84%E9%9A%BE%E7%82%B9/" title="公司自动化测试落地的难点">公司自动化测试落地的难点</a><time datetime="2024-03-28T07:55:46.000Z" title="发表于 2024-03-28 15:55:46">2024-03-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/22/%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%85%B3%E9%94%AE%E5%9C%A8%E4%BA%A4%E4%BA%92%E8%AE%BE%E8%AE%A1/" title="异步任务的体验关键在交互设计"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="异步任务的体验关键在交互设计"/></a><div class="content"><a class="title" href="/smile/2024/03/22/%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%85%B3%E9%94%AE%E5%9C%A8%E4%BA%A4%E4%BA%92%E8%AE%BE%E8%AE%A1/" title="异步任务的体验关键在交互设计">异步任务的体验关键在交互设计</a><time datetime="2024-03-22T07:55:46.000Z" title="发表于 2024-03-22 15:55:46">2024-03-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/11/Git%E5%B7%A5%E4%BD%9C%E6%B5%81/" title="Git工作流"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310261354386.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Git工作流"/></a><div class="content"><a class="title" href="/smile/2024/03/11/Git%E5%B7%A5%E4%BD%9C%E6%B5%81/" title="Git工作流">Git工作流</a><time datetime="2024-03-11T07:55:46.000Z" title="发表于 2024-03-11 15:55:46">2024-03-11</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            <a class="card-more-btn" href="/smile/categories/" title="查看更多">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/ELK/"><span class="card-category-list-name">ELK</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Gitee/"><span class="card-category-list-name">Gitee</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Java/"><span class="card-category-list-name">Java</span><span class="card-category-list-count">74</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Java/JavaSE/"><span class="card-category-list-name">JavaSE</span><span class="card-category-list-count">10</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Java/JavaWeb/"><span class="card-category-list-name">JavaWeb</span><span class="card-category-list-count">4</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Java/MySQL/"><span class="card-category-list-name">MySQL</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Java/Spring/"><span class="card-category-list-name">Spring</span><span class="card-category-list-count">7</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/smile/categories/Java/SpringBoot/"><span class="card-category-list-name">SpringBoot</span><span class="card-category-list-count">7</span></a></li></ul></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/smile/tags/docker/" style="font-size: 1.14em; color: #999a9c">docker</a> <a href="/smile/tags/%E7%BA%BF%E7%A8%8B/" style="font-size: 1.17em; color: #999ca0">线程</a> <a href="/smile/tags/windows/" style="font-size: 1.1em; color: #999">windows</a> <a href="/smile/tags/%E5%BA%8F%E5%88%97%E5%8C%96%E5%92%8C%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/" style="font-size: 1.14em; color: #999a9c">序列化和反序列化</a> <a href="/smile/tags/SQL/" style="font-size: 1.1em; color: #999">SQL</a> <a href="/smile/tags/Linux/" style="font-size: 1.32em; color: #99a2ae">Linux</a> <a href="/smile/tags/JavaScript/" style="font-size: 1.25em; color: #999fa7">JavaScript</a> <a href="/smile/tags/Java/" style="font-size: 1.5em; color: #99a9bf">Java</a> <a href="/smile/tags/git/" style="font-size: 1.1em; color: #999">git</a> <a href="/smile/tags/rabbitMQ/" style="font-size: 1.46em; color: #99a8bc">rabbitMQ</a> <a href="/smile/tags/aop/" style="font-size: 1.1em; color: #999">aop</a> <a href="/smile/tags/Socket/" style="font-size: 1.1em; color: #999">Socket</a> <a href="/smile/tags/%E5%89%8D%E7%AB%AF/" style="font-size: 1.21em; color: #999da3">前端</a> <a href="/smile/tags/SpringBoot/" style="font-size: 1.25em; color: #999fa7">SpringBoot</a> <a href="/smile/tags/%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86/" style="font-size: 1.14em; color: #999a9c">数据处理</a> <a href="/smile/tags/%E7%AB%AF%E5%8F%A3/" style="font-size: 1.14em; color: #999a9c">端口</a> <a href="/smile/tags/Gitee/" style="font-size: 1.1em; color: #999">Gitee</a> <a href="/smile/tags/MySQL/" style="font-size: 1.17em; color: #999ca0">MySQL</a> <a href="/smile/tags/%E6%80%9D%E8%80%83/" style="font-size: 1.1em; color: #999">思考</a> <a href="/smile/tags/%E5%9B%BE%E5%BA%8A/" style="font-size: 1.1em; color: #999">图床</a> <a href="/smile/tags/nvm/" style="font-size: 1.1em; color: #999">nvm</a> <a href="/smile/tags/%E4%B8%9A%E5%8A%A1/" style="font-size: 1.25em; color: #999fa7">业务</a> <a href="/smile/tags/%E9%9B%86%E5%90%88%E6%A1%86%E6%9E%B6/" style="font-size: 1.35em; color: #99a3b1">集合框架</a> <a href="/smile/tags/Selenium/" style="font-size: 1.28em; color: #99a0aa">Selenium</a> <a href="/smile/tags/IDEA/" style="font-size: 1.17em; color: #999ca0">IDEA</a> <a href="/smile/tags/%E6%B5%8B%E8%AF%95%E5%B9%B3%E5%8F%B0/" style="font-size: 1.14em; color: #999a9c">测试平台</a> <a href="/smile/tags/%E6%8E%A5%E5%8F%A3/" style="font-size: 1.32em; color: #99a2ae">接口</a> <a href="/smile/tags/%E4%B8%AD%E9%97%B4%E4%BB%B6/" style="font-size: 1.43em; color: #99a6b8">中间件</a> <a href="/smile/tags/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/" style="font-size: 1.39em; color: #99a5b5">自动化测试</a> <a href="/smile/tags/%E6%B5%8B%E8%AF%95%E6%96%B9%E6%A1%88%E8%AE%BE%E8%AE%A1/" style="font-size: 1.1em; color: #999">测试方案设计</a> <a href="/smile/tags/ELK/" style="font-size: 1.1em; color: #999">ELK</a> <a href="/smile/tags/%E4%BB%A3%E7%90%86/" style="font-size: 1.1em; color: #999">代理</a> <a href="/smile/tags/JDK/" style="font-size: 1.1em; color: #999">JDK</a> <a href="/smile/tags/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95/" style="font-size: 1.21em; color: #999da3">性能测试</a> <a href="/smile/tags/%E6%80%A7%E8%83%BD%E7%BB%9F%E8%AE%A1/" style="font-size: 1.1em; color: #999">性能统计</a> <a href="/smile/tags/JavaWeb/" style="font-size: 1.1em; color: #999">JavaWeb</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span><a class="card-more-btn" href="/smile/archives/" title="查看更多">
    <i class="fas fa-angle-right"></i></a></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2024/04/"><span class="card-archive-list-date">四月 2024</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2024/03/"><span class="card-archive-list-date">三月 2024</span><span class="card-archive-list-count">8</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2024/02/"><span class="card-archive-list-date">二月 2024</span><span class="card-archive-list-count">6</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2024/01/"><span class="card-archive-list-date">一月 2024</span><span class="card-archive-list-count">17</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2023/12/"><span class="card-archive-list-date">十二月 2023</span><span class="card-archive-list-count">13</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2023/11/"><span class="card-archive-list-date">十一月 2023</span><span class="card-archive-list-count">22</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2023/10/"><span class="card-archive-list-date">十月 2023</span><span class="card-archive-list-count">19</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/smile/archives/2023/08/"><span class="card-archive-list-date">八月 2023</span><span class="card-archive-list-count">4</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">142</div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2024-04-09T01:45:26.864Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By Xuan</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i><span id="percent">0<span>%</span></span></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)"><i class="fas fa-arrow-down"></i></button></div></div><div><script src="/smile/js/utils.js"></script><script src="/smile/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async src="https://cdn1.tianli0.top/npm/vue@2.6.14/dist/vue.min.js"></script><script async src="https://cdn1.tianli0.top/npm/element-ui@2.15.6/lib/index.js"></script><script defer src="/js/cursor.js"></script><script async src="//npm.elemecdn.com/pace-js@1.2.4/pace.min.js"></script><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/cat.js"></script><script defer data-pjax src="/js/readPercent.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --> <script data-pjax>if(document.getElementById('recent-posts') && (location.pathname ==='/'|| '/' ==='all')){
    var parent = document.getElementById('recent-posts');
    var child = '<div class="recent-post-item" style="width:100%;height: auto"><div id="catalog_magnet"><a class="magnet_link_more"  href="http://leesmile.gitee.io/smile/categories" style="flex:1;text-align: center;margin-bottom: 10px;">查看更多...</a></div></div>';
    console.log('已挂载magnet')
    parent.insertAdjacentHTML("afterbegin",child)}
     </script><style>#catalog_magnet{flex-wrap: wrap;display: flex;width:100%;justify-content:space-between;padding: 10px 10px 0 10px;align-content: flex-start;}.magnet_item{flex-basis: calc(50% - 5px);background: #87CEFA;margin-bottom: 10px;border-radius: 8px;transition: all 0.2s ease-in-out;}.magnet_item:hover{background: #00FFFF}.magnet_link_more{color:#555}.magnet_link{color:black}.magnet_link:hover{color:white}@media screen and (max-width: 600px) {.magnet_item {flex-basis: 100%;}}.magnet_link_context{display:flex;padding: 10px;font-size:16px;transition: all 0.2s ease-in-out;}.magnet_link_context:hover{padding: 10px 20px;}</style>
    <style></style><script data-pjax>
  function butterfly_footer_beautify_injector_config(){
    var parent_div_git = document.getElementById('footer-wrap');
    var item_html = '<div id="workboard"></div><p id="ghbdages"><a class="github-badge" target="_blank" href="https://hexo.io/" style="margin-inline:5px" data-title="博客框架为Hexo_v6.2.0" title=""><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&amp;logo=hexo" alt=""/></a><a class="github-badge" target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" data-title="主题版本Butterfly_v4.3.1" title=""><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&amp;logo=bitdefender" alt=""/></a><a class="github-badge" target="_blank" href="https://gitee.com/" style="margin-inline:5px" data-title="本站项目由Gitee托管" title=""><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&amp;logo=GitHub" alt=""/></a><a class="github-badge" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" style="margin-inline:5px" data-title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可" title=""><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&amp;logo=Claris" alt=""/></a></p>';
    console.log('已挂载butterfly_footer_beautify')
    parent_div_git.insertAdjacentHTML("beforeend",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_footer_beautify_injector_config();
  }
  else if (epage === cpage){
    butterfly_footer_beautify_injector_config();
  }
  </script><script async src="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.js"></script><!-- hexo injector body_end end --></body></html>